<?php
/**
 * @package Component Metromap for Joomla! 1.5
 * @version $Id: view.html.php 4 2010-08-17 13:58:48Z batyrkin $
 * @author Batyrkin Anton
 * @copyright (C) 2010- Batyrkin Anton
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/

defined( '_JEXEC' ) or die();
jimport( 'joomla.application.component.view' );

/**
 * LinesList View
 */
class MetromapViewMetromapLines extends JView
{

	function display($tpl = null)
	{

		global $mainframe;
		$document	=& JFactory::getDocument();
		$uri		=& JFactory::getURI();

		JHTML::stylesheet( 'metromap.css', 'administrator/components/com_metromap/assets/' );
		// Set toolbar items for the page
		JToolBarHelper::title(   JText::_( 'Lines Manager' ), 'station' );
		//JToolBarHelper::publishList();
		//JToolBarHelper::unpublishList();
		JToolBarHelper::deleteList(  JText::_( 'WARNWANTDELLISTEDITEMS' ), 'remove', 'delete');
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();
		JToolBarHelper::help( 'screen.metromap', true );

		//Filter
		$context			= 'com_metromap.lines.list.';
		$filter_state		= $mainframe->getUserStateFromRequest( $context.'filter_state',	'filter_state',	'',	'word' );
		$filter_order		= $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order',	'a.ordering','cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( $context.'filter_order_Dir',	'filter_order_Dir',	'',	'word' );
		$search				= $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' );
		$search				= JString::strtolower( $search );

		// Get data from the model
		$items		= & $this->get( 'Data');
		$total		= & $this->get( 'Total');
		$pagination = & $this->get( 'Pagination' );

		// build list of categories
		$javascript 			= 'onchange="document.adminForm.submit();"';

		// state filter
		$lists['state']			= JHTML::_('grid.state',  $filter_state );

		// table ordering
		$lists['order_Dir'] 	= $filter_order_Dir;
		$lists['order'] 		= $filter_order;

		// search filter
		$lists['search']		= $search;

		$ordering = ($lists['order'] == 'a.ordering');//Ordering allowed ?

		$this->assignRef('user',		JFactory::getUser());
		$this->assignRef('lists',		$lists);
		$this->assignRef('items',		$items);
		$this->assignRef('total',		$total);
		$this->assignRef('pagination',	$pagination);
		$this->assignRef('ordering', 	$ordering);
		$this->assignRef('request_url',	htmlspecialchars($uri->toString()));

		parent::display($tpl);
	}
}